package de.bensoft.server.model.entity;

import javax.persistence.*;

/**
 * **************************************************
 * ***        THIS FILE IS COPYRIGHT BY          ****
 * ***              Michael Benoit               ****
 * **************************************************
 * User: michael
 * Date: 15.11.13
 * Time: 17:31
 */

@NamedQueries({
        @NamedQuery(name = Locomotive.GET_ALL_LOCOMOTIVES, query = "SELECT l FROM Locomotive")
})

@Entity
public class Locomotive {

    public static final String GET_ALL_LOCOMOTIVES = "GetAllLocomotives";

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long    id;
    private String  name;
    private Long    address;
    private Long    speedSteps;


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Long getAddress() {
        return address;
    }

    public void setAddress(Long address) {
        this.address = address;
    }

    public Long getSpeedSteps() {
        return speedSteps;
    }

    public void setSpeedSteps(Long speedSteps) {
        this.speedSteps = speedSteps;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Locomotive that = (Locomotive) o;

        if (!address.equals(that.address)) return false;
        if (!id.equals(that.id)) return false;
        if (!name.equals(that.name)) return false;
        if (!speedSteps.equals(that.speedSteps)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id.hashCode();
        result = 31 * result + name.hashCode();
        result = 31 * result + address.hashCode();
        result = 31 * result + speedSteps.hashCode();
        return result;
    }
}
